using Brain;
#if !MONOGAME
using Brain.Dev;
#endif
using Brain.Rendering;
using Microsoft.Xna.Framework;
using System;
using System.IO;
using System.Threading;
using Microsoft.Xna.Framework.Graphics;
using Brain.Logic.AI;
using Brain.SunBurn;
using SynapseGaming.LightingSystem.Rendering;

namespace Demos
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth = 1920;
            graphics.PreferredBackBufferHeight = 1080;
            graphics.IsFullScreen = true;

            SplashScreenGameComponent splash = new SplashScreenGameComponent(this);
            this.Components.Add(splash);
        }

        protected override void Initialize()
        {
            base.Initialize();

            Engine.InitializeEngineWithDefaultManagers(this.graphics);
            Engine.Instance.OnDevelopment = true;

            Engine.Instance.AssignGame(this);

#if DEBUG
            //Engine.Instance.AddManager(new DefaultDebugManager());
#endif
            Engine.Instance.AddManager(new DefaultRenderManager2D(this.GraphicsDevice));
            Engine.Instance.AddManager(new SunBurnRenderManager3D(this.GraphicsDevice, RenderingSystemType.Deferred));

            Engine.Instance.AddManager(new DefaultAIManager());
            Engine.Instance.AddManager(new SunBurnStereoscopicManager());

            new MainMenuScreen();
        }

        protected override void UnloadContent()
        {
            base.UnloadContent();

            Engine.Instance.Unload();
        }

        protected override void Update(GameTime gameTime)
        {
            if (!SplashScreenGameComponent.DisplayComplete)
            {
                base.Update(gameTime);
                return;
            }
            base.Update(gameTime);

            Engine.Instance.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            if (!SplashScreenGameComponent.DisplayComplete)
            {
                base.Draw(gameTime);
                return;
            }
            base.Draw(gameTime);

            Engine.Instance.Draw(gameTime);
        }
    }
}
